

#include "CEntity.h"
#include "CGameApp.h"


//using namespace std;

CEntity::CEntity()
:m_iTexture(0),
m_pFireAnimationTexture(NULL),
m_iFireAnimationSize(3),
m_iFireAnimationFrame(0),
m_fFireAnimationFrameDelay(0.03f),
m_fFireAnimationTimer(0),
m_bFireAnimationAlive(0),
FirePos(0,0),
m_pExplosionTexture(NULL),
m_iExplosionFrame(0),
m_iExplosionSize(10),
m_fExplosionFrameDelay(0.04f),
m_fExplosionTimer(0),
m_fSpeed(0.0f),
m_fRotateSpeed(0.0f),
m_bAlive(0),
m_bExplosionAlive(0),
m_fMaxDamageTime(1.3f),
m_bDamageAlive(0),
m_fHealth(0),
m_fFaceAngle(0),
m_fSize(0),
m_fRadius(0),
m_fCollisionSize(0),
m_fCollisionRadius(0),
m_fDistanceToPlayer(999),
m_fLifeSpan(99999),
m_sType(""),
m_iShape(CIRCLE),
m_bLaserFiring(false),
Breakable(false),
m_fLaserLength(0),
pParent(0)
{
	m_pFireAnimationTexture = new int[ GetFTextureSize() ];
	m_pExplosionTexture = new int[GetETextureSize()];
	Collision[CIRCLE][CIRCLE]	= &CEntity::CircleCircleCollision;
	Collision[CIRCLE][LINE]		= &CEntity::CircleLineCollision;
	Collision[CIRCLE][SQUARE]	= &CEntity::CircleSquareCollision;
	Collision[LINE][CIRCLE]		= &CEntity::LineCircleCollision;
	Collision[LINE][LINE]		= &CEntity::LineLineCollision;
	Collision[LINE][SQUARE]		= &CEntity::LineSquareCollision;
	Collision[SQUARE][CIRCLE]	= &CEntity::SquareCircleCollision;
	Collision[SQUARE][LINE]		= &CEntity::SquareLineCollision;
	Collision[SQUARE][SQUARE]	= &CEntity::SquareSquareCollision;


}

CEntity::~CEntity()
{
	if( m_pFireAnimationTexture ) { delete[] m_pFireAnimationTexture; }
	if( m_pExplosionTexture ) { delete[] m_pExplosionTexture; }
}

void CEntity::Render()
{
	static float special = 1.0f;
	if( GetType() == "CEnemyCBounceWeapon" ) { special = 0.0f; }
	else { special = 1.0f; }
	//if( GetType() == "CEnemyCBounceWeapon" ) { glColor4f( 1.0f, 0.0f, 0.0f, 1.0f ); }
	//else { glColor4f(1.0f,1.0f,1.0f,1.0f); }
	glColor4f( 1.0f, special, special, 1.0f );
	static float start = 0.0f;
	static float end = 1.0f;
	//float startx = blockswide* i/blockswide;
	//float starty = blockshigh* i/blockshigh;
	//float endx   = blockswide* i/blockswide + blockwidth;
	//float faceangle = GetFaceAngle();
	//RotateFaceAngleBy( 135.0f );
//	float tlx = GetPosX()-GetRadius(); float tly = GetPosY()+GetRadius();
	//RotateFaceAngleBy( 90.0f );
//	float blx = GetPosX()-GetRadius(); float bly = GetPosY()-GetRadius();
	//RotateFaceAngleBy( 90.0f );
//	float brx = GetPosX()+GetRadius(); float bry = GetPosY()-GetRadius();
	//RotateFaceAngleBy( 90.0f );
//	float trx = GetPosX()+GetRadius(); float tryr =GetPosY()+GetRadius();
	//SetQuad();
	//cout << "topleftx " << topleftx << "toprightx " << toprightx << endl; 
//	float tlx = -GetRadius();		 	float tly = GetRadius();
//	float blx = -GetRadius();			float bly = -GetRadius();
//	float brx = GetRadius();			float bry = -GetRadius();
//	float trx = GetRadius();			float tryr = GetRadius();

	//SetFaceAngle( faceangle );
	//tlx += GetVelX(); tly += GetVelY();
	//trx += GetVelX(); tryr += GetVelY(); brx += GetVelX(); bry += GetVelY();
	//float xrotn = (-cos((GetFaceAngle())*0.0174533f)) * (GetPosX()-GetRadius());
	//float yrotn = (-sin((GetFaceAngle())*0.0174533f)) * (GetPosY()-GetRadius());
	//float xrotp = (cos((GetFaceAngle())*0.0174533f)) * (GetPosX()+GetRadius());
	//float yrotp = (sin((GetFaceAngle())*0.0174533f)) * (GetPosY()+GetRadius());

	if( GetAlive() )
	{

		//pathetic first attempt at making bullet trails
		//glBindTexture( GL_TEXTURE_2D, 0 );
		////glColor4f( 1,1,1,1 );
		//glBegin( GL_LINES );
		//	glVertex2f( GetOldPosX() - GetVelX() , GetOldPosY() - GetVelY() );
		//	glVertex2f( GetPosX(), GetPosY() );
		//glEnd();




		glBindTexture( GL_TEXTURE_2D , GetTexture() );

		//rotate image
		//glMatrixMode(GL_TEXTURE);
		//glLoadIdentity();
//		glTranslatef(0.5,0.5,0.0);
		
		//glScalef( 1.5f, 1.5f, 1.0f );
//		glTranslatef(-0.5,-0.5,0.0);
		//glMatrixMode(GL_MODELVIEW); 

//		for( float i = 0; i < 10; i += 0.25f )
//		{
//			glPushMatrix();
//			glTranslatef( GetPosX()-GetVelX()*i, GetPosY()-GetVelY()*i, 0 );
//			glRotatef( GetFaceAngle(), 0, 0, 1 );
//			
//			glBegin( GL_QUADS );
//
//			glColor4f( 1.0f , special, special , 1.0f-i*0.1f );
/////////////////////////////////////
//			glTexCoord2f( start, start );					//top left
//			glVertex2f( topleftx, toplefty );
//			//glVertex2f( GetPosX()-GetRadius(),GetPosY()+GetRadius() );				 //first //second
//						
//			glTexCoord2f( start, end );					//bottom left
//			glVertex2f( bottomleftx , bottomlefty );
//			//glVertex2f( GetPosX()-GetRadius(),GetPosY()-GetRadius() );		 //first
//
//			glTexCoord2f( end, end );					//bottom right
//			glVertex2f( bottomrightx  , bottomrighty  );
//			//glVertex2f( GetPosX()+GetRadius(),GetPosY()-GetRadius() );			//first //second
//
//			glTexCoord2f( end, start );					//top right
//			glVertex2f( toprightx , toprighty  );
//
//
//			glEnd();
//
//			glPopMatrix();
//		}




		glPushMatrix();
		glTranslatef( GetPosX(), GetPosY(), 0.0f );
		glRotatef( GetFaceAngle(),0.0,0.0,1.0);
		
		//draw it
		glBegin( GL_QUADS ); //triangle fan
			//trail
/*			for( float i= 0; i< 3; i+=0.1f )
			{
			glColor4f( 1.0f , special, special , 1.0f-i*.5f );
///////////////////////////////////
			glTexCoord2f( start, start );					//top left
			glVertex2f( topleftx + GetVelX(), toplefty + GetVelY() );
			//glVertex2f( GetPosX()-GetRadius(),GetPosY()+GetRadius() );				 //first //second
						
			glTexCoord2f( start, end );					//bottom left
			glVertex2f( bottomleftx + GetVelX(), bottomlefty + GetVelY() );
			//glVertex2f( GetPosX()-GetRadius(),GetPosY()-GetRadius() );		 //first

			glTexCoord2f( end, end );					//bottom right
			glVertex2f( bottomrightx + GetVelX() , bottomrighty + GetVelY() );
			//glVertex2f( GetPosX()+GetRadius(),GetPosY()-GetRadius() );			//first //second

			glTexCoord2f( end, start );					//top right
			glVertex2f( toprightx + GetVelX() , toprighty + GetVelY() );
			}
*/
			//for( float i = 0.0f; i <= 2.0f; i += 0.1f )
			//{
			//glColor4f( 1.0f, special, special, 1-i*0.5f );
			//glTexCoord2f( start, start );					//top left
			//glVertex2f( GetOldPosX() - GetVelX()*i-GetRadius(),GetOldPosY() - GetVelY()*i+GetRadius() );				 //first //second
			//			
			//glTexCoord2f( start, end );					//bottom left
			//glVertex2f( GetOldPosX() - GetVelX()*i-GetRadius(),GetOldPosY() - GetVelY()*i-GetRadius() );		 //first

			//glTexCoord2f( end, end );					//bottom right
			//glVertex2f( GetOldPosX() - GetVelX()*i+GetRadius(),GetOldPosY() - GetVelY()*i-GetRadius() );			//first //second

			//glTexCoord2f( end, start );					//top right
			//glVertex2f( GetOldPosX() - GetVelX()*i+GetRadius(),GetOldPosY() - GetVelY()*i+GetRadius() );          //second
			//}

//SetVel( cos((GetFaceAngle())*0.0174533f), sin((GetFaceAngle())*0.0174533f) );

			glColor4f( 1.0f , special, special , 1.0f );
///////////////////////////////////
			glTexCoord2f( start, start );					//top left
			glVertex2f( topleftx, toplefty );
			//glVertex2f( GetPosX()-GetRadius(),GetPosY()+GetRadius() );				 //first //second
						
			glTexCoord2f( start, end );					//bottom left
			glVertex2f( bottomleftx , bottomlefty );
			//glVertex2f( GetPosX()-GetRadius(),GetPosY()-GetRadius() );		 //first

			glTexCoord2f( end, end );					//bottom right
			glVertex2f( bottomrightx , bottomrighty );
			//glVertex2f( GetPosX()+GetRadius(),GetPosY()-GetRadius() );			//first //second

			glTexCoord2f( end, start );					//top right
			glVertex2f( toprightx , toprighty );
			//glVertex2f( GetPosX()+GetRadius(),GetPosY()+GetRadius() );          //second

		glEnd();

		if( GetDAlive() )
		{
			glBindTexture( GL_TEXTURE_2D , GetDTexture() );
			glColor4f( 1.0f, 1.0f, 1.0f, 1-(GetDTimer()/GetMaxDamageTime()) );
			glBegin( GL_QUADS );
				glTexCoord2f( start, start );					//top left
				glVertex2f( topleftx, toplefty );
				//glVertex2f( GetPosX()-GetRadius(),GetPosY()+GetRadius() );				 //first //second
							
				glTexCoord2f( start, end );					//bottom left
				glVertex2f( bottomleftx , bottomlefty );
				//glVertex2f( GetPosX()-GetRadius(),GetPosY()-GetRadius() );		 //first

				glTexCoord2f( end, end );					//bottom right
				glVertex2f( bottomrightx , bottomrighty );
				//glVertex2f( GetPosX()+GetRadius(),GetPosY()-GetRadius() );			//first //second

				glTexCoord2f( end, start );					//top right
				glVertex2f( toprightx , toprighty );
			glEnd();
		}

//draw the explosion if active
	
		glPopMatrix();

		glPushMatrix();
		glTranslatef( GetFirePosX(), GetFirePosY(), 0.0f );
		glRotatef( GetFaceAngle(),0.0,0.0,1.0);
		
		
		//glTranslatef( 0.0f, 0.0f, 0.0f );
		if( GetFAlive() )//== false ) { return; }
		{

			glBindTexture( GL_TEXTURE_2D, GetFTexture(GetFFrame()) );

			//GetRadius()*s
			float s = 2.7f;//2.4f;//explosion size
			glBegin( GL_QUADS ); //triangle fan
				glTexCoord2f( start, start );					//top left
				glVertex2f( -GetRadius()*s,GetRadius()*s );				 //first //second
							
				glTexCoord2f( start, end );					//bottom left
				glVertex2f( -GetRadius()*s,-GetRadius()*s );		 //first

				glTexCoord2f( end, end );					//bottom right
				glVertex2f( GetRadius()*s,-GetRadius()*s );			//first //second

				glTexCoord2f( end, start );					//top right
				glVertex2f( GetRadius()*s,GetRadius()*s );          //second
			glEnd();
		}
		glPopMatrix();

	}//endif entity is alive//

#if 1
	if( pParent->GameSpeed > 1.01f )
	{
	//draw the collision circle
	const float PI = 3.14159f;
	float nextstep = 2.0f*PI/8.0f;
	float r = GetCollisionRadius();
	float cx = GetPosX();
	float cy = GetPosY();
	float ocx = GetOldPosX();
	float ocy = GetOldPosY();

	glBindTexture( GL_TEXTURE_2D, 0 );
	glBegin( GL_LINE_LOOP );
	glColor4f( 0.0f, 1.0f, 0.0f, 1.0f );
 
	for( float t = 0.0f; t < PI*2; t+= nextstep )
	{
		float x = r * cosf( t ) + cx;
		float y = r * sinf( t ) + cy;
		glVertex2f( x, y );
	}

	glColor4f( 0.0f, 0.0f, 1.0f, 1.0f );
	for( float t = 0.0f; t < PI*2; t+= nextstep )
	{
		float x = r * cosf( t ) + ocx;
		float y = r * sinf( t ) + ocy;
		glVertex2f( x, y );
	}

	glEnd();
	}
#endif


	//draw the explosion if active
	if( GetEAlive() == false ) { return; }

	glBindTexture( GL_TEXTURE_2D, GetETexture(GetEFrame()) );

	//glMatrixMode(GL_TEXTURE);
	//glLoadIdentity();
	//glTranslatef(0.5,0.5,0.0);
	//glRotatef( GetFaceAngle(),0.0,0.0,1.0);
	//glTranslatef(-0.5,-0.5,0.0);
	//glMatrixMode(GL_MODELVIEW); 

	glPushMatrix();
	glTranslatef( GetPosX(), GetPosY(), 0.0f );
	glRotatef( GetFaceAngle(),0.0,0.0,1.0);

	float s = 2.4f;//explosion size
	glBegin( GL_QUADS ); //triangle fan
		glTexCoord2f( start, start );					//top left
		glVertex2f( -GetRadius()*s,GetRadius()*s );				 //first //second
					
		glTexCoord2f( start, end );					//bottom left
		glVertex2f( -GetRadius()*s,-GetRadius()*s );		 //first

		glTexCoord2f( end, end );					//bottom right
		glVertex2f( GetRadius()*s,-GetRadius()*s );			//first //second

		glTexCoord2f( end, start );					//top right
		glVertex2f( GetRadius()*s,GetRadius()*s );          //second
	glEnd();

	glPopMatrix();

}

void CEntity::Update()
{
	//have an array of function pointers with timers that count down and activate the functions when the timers run out
	//for each element in the array
	//	lower the timer
	//	if timer <= 0
	//		call the function
	//		delete the element in the array
	//next element in the array



	if( GetAlive() )
	{
		SetLifeSpan( GetLifeSpan() - pParent->DeltaTime );
		if( GetLifeSpan() <= 0.0f ) { Kill(); }
		if( GetFAlive() )	{ UpdateFireAnimation(); }
		if( GetDAlive() )	{ UpdateDamageAnimation(); }
	}
	if( GetEAlive() )
	{
		UpdateExplosion();
	}
	//if( GetAlive() == false && GetEAlive() == false )
	//{
		//SetAlive( true );
	//}
}

float CEntity::GetDistanceTo( CEntity* target )
{
	//this function can be optimizied by removing the square root if it turns out the exact distance isn't neccessary
	float x = this->GetPosX() - target->GetPosX();
	float y = GetPosY() - target->GetPosY();
	
	//float z = sqrtf( x*x + y*y );
	return sqrtf( x*x + y*y ) - GetRadius();
}


void CEntity::StartFireAnimation()
{
	SetFFrame( 0 );
	SetFAlive( true );
	SetFTimer( 0 );
	SetFirePos( GetPosX(), GetPosY() );
}

void CEntity::UpdateFireAnimation()
{
	//set the fire animation to the proper frame. if time is up, kill it
	SetFTimer( GetFTimer() + pParent->DeltaTime );
	SetFFrame( int( GetFTimer()/GetFFrameDelay() ) );
	//if the frame is out of bounds, then the explosion is done
	if( GetFFrame() >= GetFTextureSize() )
	{
		SetFFrame( 0 );
		SetFTimer( 0 );
		SetFAlive( false );
	}

	//the frame equals the total time passed between the delays
	//delay == 0.2    totalTimePassed == .35 seconds
	//frame would be the second one  timePassed/delay turned into an int
	// .03/.2 = 0 correct
	// .5/.2  = 2 correct third frame
	// .9/.2  = 4 correct fifth frame
	// 1.1/.2 = 5 too far sixth frame

}

void CEntity::StartExplosion()
{
	SetEFrame( 0 );
	SetEAlive( true );
	SetETimer( 0 );
}

void CEntity::StartDamageAnimation()
{
	SetDTimer( 0 );
	SetDAlive( true );
}

void CEntity::UpdateDamageAnimation()
{
	SetDTimer( GetDTimer() + pParent->DeltaTime );
	float time = GetDTimer()/GetMaxDamageTime();
	if( time >= GetMaxDamageTime() )
	{
		SetDTimer( 0 );
		SetDAlive( false );
	}
}

void CEntity::UpdateExplosion()
{
	//set the explosion to the proper frame. if time is up, kill it
	SetETimer( GetETimer() + pParent->DeltaTime );
	SetEFrame( int( GetETimer()/GetEFrameDelay() ) );
	//if the frame is out of bounds, then the explosion is done
	if( GetEFrame() >= GetETextureSize() )
	{
		SetEFrame( 0 );
		SetETimer( 0 );
		SetEAlive( false );
	}

	//the frame equals the total time passed between the delays
	//delay == 0.2    totalTimePassed == .35 seconds
	//frame would be the second one  timePassed/delay turned into an int
	// .03/.2 = 0 correct
	// .5/.2  = 2 correct third frame
	// .9/.2  = 4 correct fifth frame
	// 1.1/.2 = 5 too far sixth frame

}

void CEntity::TakeDamage( float damage )
{
	SetHealth( GetHealth() - damage );
	if( GetHealth() <= 0 )
	{
		Kill();
		//SetAlive( false );
		//StartExplosion();
	}
}

void CEntity::Kill()
{
	SetAlive( false );
	SetFAlive( false );
	SetDTimer( GetMaxDamageTime() );
	StartExplosion();
	//SetPos( -9999 , -9999 );
	//SetLifeSpan( 99999 );
}


bool CEntity::CircleCircleCollision( CEntity* test )
{
	if( test == NULL ) { cout << "no collision, entity was null" << endl; return false; }
	//this function will damage the test object                        

	//if either object is dead, no collisions will happen
	if( GetAlive() == false ) { return false; }
	if( test->GetAlive() == false ) { return false; }

	//input vector minus this vector
	float cx = test->Pos.x - Pos.x;
	float cy = test->Pos.y - Pos.y;

	//find it's length
	float length = sqrt( cx*cx + cy*cy );

	//if it's less than this radius + test's radius, then collision
	if( length < test->GetCollisionRadius() + GetCollisionRadius() )
	{
		//collision
		//test->TakeDamage();
		return true;
	}
	return false;
}

bool CEntity::CircleLineCollision( CEntity* test )
{
	return false;
}

bool CEntity::CircleSquareCollision( CEntity* test )
{
/*		float minx = Ship->pParent->Block[i]->GetPosX() - Ship->pParent->Block[i]->GetRadius();
		float maxx = Ship->pParent->Block[i]->GetPosX() + Ship->pParent->Block[i]->GetRadius();
		float miny = Ship->pParent->Block[i]->GetPosY() - Ship->pParent->Block[i]->GetRadius();
		float maxy = Ship->pParent->Block[i]->GetPosY() + Ship->pParent->Block[i]->GetRadius();

				CEntity* bullet = Bullets[x][y];
				if( bullet->GetAlive() == false ) { continue; }
				float cr    = bullet->GetCollisionRadius();
				float bminx = bullet->GetPosX() - cr;
				float bmaxx = bullet->GetPosX() + cr;
				float bminy = bullet->GetPosY() - cr;
				float bmaxy = bullet->GetPosY() + cr;
				if( bminx > maxx ) { continue; } //bullet to the right, no collision
				if( bmaxx < minx ) { continue; } //bullet to the left, no collision
				if( bminy > maxy ) { continue; } //bullet above, no collision
				if( bmaxy < miny ) { continue; } //bullet below, no collision
*/
	return false;
}

bool CEntity::LineCircleCollision( CEntity* test )
{
	if( test == NULL ) { cout << "no collision, entity was null" << endl; return false; }
	//this function will damage the test object                        

	//if either object is dead, no collisions will happen
	if( GetAlive() == false ) { return false; }
	if( test->GetAlive() == false ) { return false; }
	//Bullets[x][y]->SetOldPos( Bullets[x][y]->GetPosX(), Bullets[x][y]->GetPosY() );
	//		Bullets[x][y]->SetPos( Ship->GetPosX() + Ship->GetVelX()*Ship->GetRadius(),Ship->GetPosY() + Ship->GetVelY()*Ship->GetRadius() );
	//		Bullets[x][y]->SetFaceAngle( Ship->GetFaceAngle() - (((Spread - 1)*SpreadAngle)/2 ) + y * SpreadAngle );
	//		SetLineEnd( LaserLength );

	//		//this is where i update the ending position of the laser
	//		//to do this i need to go through all ships and level data and see if there's a collision
			float final = GetLaserLength();
	//		int	  enemyhit = pParent->NumEnemies;
	//		for( int i = 0; i < pParent->NumEnemies; i++ )
	//		{
	//			CEnemy* enemy = pParent->Enemy[i];
	//			if( enemy->GetAlive() == false ) { continue; }
				float gunx = GetPosX();						float guny = GetPosY();
				float endx = gunx + GetVelX()*GetLaserLength();	float endy = guny + GetVelY()*GetLaserLength();
				float cirx = test->GetPosX();				float ciry = test->GetPosY();
				float r	   = test->GetCollisionRadius();

				float dx = endx - gunx;									float dy = endy - guny;
				float fx = gunx - cirx;									float fy = guny - ciry;
				float a = dx*dx + dy*dy;
				float b = 2 * ( fx*dx + fy*dy );
				float c = fx*fx + fy*fy - r*r;
				float disc = b*b - 4*a*c;
				if( disc < 0 )
				{
					//no intersection
					//SetLineEnd( LaserLength );
					return false;//continue;
				}
				else
				{
					disc = sqrtf( disc );
					float t1 = (-b + disc)/(2*a);
					float t2 = (-b - disc)/(2*a);
					if( t1 >= 0 && t1 <= 1 )
					{
						if( t1 * GetLaserLength() < final ) { final = t1* GetLaserLength(); }//enemyhit = i; }
					}
					if( t2 >= 0 && t2 <= 1 )
					{
						if( t2 * GetLaserLength() < final ) { final = t2* GetLaserLength(); }//enemyhit = i; } 
	//					//SetLineEnd( t2 * LaserLength);
	//					//LaserLength = LaserLength * t1;
	//					//x = cos( angle ) * r * t + xpos
	//					//y = sin( angle ) * r * t + ypos
					}
					//else
	//				//{
	//				//	SetLineEnd( t2 * LaserLength );
	//				//}
				}
	//		}
			if( final < GetLaserLength() )
			{
				SetLineEnd( final );
				return true;
			}

	return false;
}

bool CEntity::LineLineCollision( CEntity* test )
{
	return false;
}

bool CEntity::LineSquareCollision( CEntity* test )
{
	return false;
}

bool CEntity::SquareCircleCollision( CEntity* test )
{
	return false;
}

bool CEntity::SquareLineCollision( CEntity* test )
{
	return false;
}

bool CEntity::SquareSquareCollision( CEntity* test )
{

	return false;
}


void CEntity::Load()
{

}


void CEntity::SetFaceAngle( float angle )
{ 
	m_fFaceAngle = angle;
	SetVel( cos(GetFaceAngle()*0.0174533f), sin(GetFaceAngle()*0.0174533f) );
	//m_fFaceAngle -= 90;
}

void CEntity::SetFaceAngle( float x, float y )
{
	x -= GetPosX();
	y -= GetPosY();

	if( x < 0 )		{ SetFaceAngle( (atan( y/x )*57.2958f)+180 ); }
	if( x >= 0 )	{ SetFaceAngle( atan( y/x )*57.2958f ); }
}

//void CEntity::PointTo( float x, float y )
//{
//	x -= GetPosX();
//	y -= GetPosY();
//
//	SetFaceAngle( x, y );
//}

void CEntity::RotateFaceAngleBy( float angle )
{ 
	m_fFaceAngle += angle; 
	SetVel( cos((GetFaceAngle())*0.0174533f), sin((GetFaceAngle())*0.0174533f) );
}

void CEntity::SetFireAnimationTexture( Texture* texs )
{
	if( texs == NULL )	{ cout << "no good" << endl; }
	for( int i = 0; i < GetFTextureSize(); i++ )
	{
		m_pFireAnimationTexture[i] = texs[i].texID;
	}
}

void CEntity::SetExplosionTexture( Texture* texs )
{
	if( texs == NULL )	{ cout << "no good" << endl; }
	for( int i = 0; i < GetETextureSize(); i++ )
	{
		m_pExplosionTexture[i] = texs[i].texID;
	}
}

void CEntity::SetLineEnd( float length )
{
	//sets the toprightx and y and bottomright x and y values to that of the collision point
	toprightx		= topleftx + GetSize() + length;
	bottomrightx	= bottomleftx + GetSize() + length;

}

void CEntity::SetQuad()
{
	topleftx = -GetRadius();		toplefty = GetRadius();
	bottomleftx = -GetRadius();		bottomlefty = -GetRadius();
	bottomrightx = GetRadius();		bottomrighty = -GetRadius();
	toprightx = GetRadius();		toprighty = GetRadius();
}
